package com.iterator.controller.wechat.lc;

import com.iterator.bean.web.pojo.BaseRespVo;
import com.iterator.bean.web.pojo.zql.Topic;
import com.iterator.bean.wechat.lc.WxTopicDetailVo;
import com.iterator.service.wechat.lc.WxTopicServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("wx/topic")
public class WxTopicController {
    @Autowired
    WxTopicServiceImpl topicService;
    @RequestMapping("list")
    public BaseRespVo list(@RequestParam("page") Integer page,@RequestParam("size") Integer size){
        Map<String,Object> topicList =topicService.getList(page,size);
        return BaseRespVo.ok(topicList);
    }
    @RequestMapping("detail")
    public BaseRespVo detail(@RequestParam Integer id){
        WxTopicDetailVo detailVo = topicService.getDetail(id);
        return BaseRespVo.ok(detailVo);
    }

    /**
     * 返回随机related topics
     * @param id
     * @return
     */
    @RequestMapping("related")
    public BaseRespVo related(@RequestParam Integer id){
        List<Topic> topics = topicService.getRelated(id);
        return BaseRespVo.ok(topics);
    }
}
